# Not part the main project, but this PowerShell 2.0 script may prove useful in enabling/disabling
# ISA rules

function ChangeRule([string]$rulename, [bool]$state)
{
	# modify specified rule to specified state
	$root = new-object -comobject "FPC.Root" -strict
	$arr = $root.Arrays | select-object -first 1

	$rule = $arr.ArrayPolicy.PolicyRules | where { $_.Name -eq $rulename }
	if ($rule -eq $null -or $rule -is [array])
	{
		throw "Cannot find rule: $rulename"
	}

	if ($rule.Enabled -ne $state)
	{
		$rule.Enabled = $state
		$rule.save()
	}
}

function GetRuleState([string]$rulename)
{
	# get requested rule state, true or false (enabled or disabled)
	$root = new-object -comobject "FPC.Root" -strict
	$arr = $root.Arrays | select-object -first 1

	$rule = $arr.ArrayPolicy.PolicyRules | where { $_.Name -eq $rulename }
	if ($rule -eq $null -or $rule -is [array])
	{
		throw "Cannot find rule: $rulename"
	}

	$rule.Enabled
}

$myrule = "Your rule name on ISA"


$current = getrulestate $myrule
echo "Current state of `"$myrule`" is $current"

$newstate = !$current
echo "Setting to $newstate ..."
changerule $myrule $newstate

echo "New state is..."
getrulestate $myrule
